package ar.edu.itba.tp1.tpmariano;

import ar.edu.itba.tp1.gps.api.GPSRule;
import ar.edu.itba.tp1.gps.api.GPSState;
import ar.edu.itba.tp1.gps.exception.NotAppliableException;

public class SwapGPSRule implements GPSRule {

	protected int srcX;
	protected int srcY;
	protected int dstX;
	protected int dstY;

	public SwapGPSRule(int srcX, int srcY, int dstX, int dstY) {
		super();
		this.srcX = srcX;
		this.srcY = srcY;
		this.dstX = dstX;
		this.dstY = dstY;
	}

	@Override
	public String getName() {
		return "SWAP RULE: (" + srcX + "," + srcY + ") to (" + dstX + "," + dstY + ")";
	}

	@Override
	public GPSState evalRule(GPSState state) throws NotAppliableException {
		/*((Grid) state).swap(srcX, srcY, dstX, dstY);
		return state;*/
		GPSState ans = state.copyState();
		((Grid) ans).swap(srcX, srcY, dstX, dstY);
		return ans;
	}

	@Override
	public Integer getCost() {
		return 1;
	}
}
